<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="商品编码" prop="productCode">
        <el-input
          v-model.trim="queryParams.productCode"
          placeholder="请输入商品编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品名称" prop="productName">
        <el-input
          v-model.trim="queryParams.productName"
          placeholder="请输入商品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="文档名称" prop="docName">
        <el-input
          v-model.trim="queryParams.docName"
          placeholder="请输入文档名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>

      <div v-if="isOpen">
        <el-form-item label="编码时间" prop="encodedTime">
          <el-date-picker
            clearable
            v-model="queryParams.encodedTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择编码时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="商品简称" prop="productShortName">
          <el-input
            v-model.trim="queryParams.productShortName"
            placeholder="请输入商品简称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料类别" prop="materialCategory">
          <el-input
            v-model.trim="queryParams.materialCategory"
            placeholder="请输入物料类别"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料形态" prop="materialForm">
          <el-input
            v-model.trim="queryParams.materialForm"
            placeholder="请输入物料形态"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="教材版本" prop="textbookVersion">
          <el-input
            v-model.trim="queryParams.textbookVersion"
            placeholder="请输入教材版本"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="教育阶段" prop="educationStage">
          <el-input
            v-model.trim="queryParams.educationStage"
            placeholder="请输入教育阶段"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="年级" prop="gradeLevel">
          <el-input
            v-model.trim="queryParams.gradeLevel"
            placeholder="请输入年级"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="学科类别" prop="subjectCategory">
          <el-input
            v-model.trim="queryParams.subjectCategory"
            placeholder="请输入学科类别"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="学科组合" prop="subjectCombination">
          <el-input
            v-model.trim="queryParams.subjectCombination"
            placeholder="请输入学科组合"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="册别" prop="unitName">
          <el-input
            v-model.trim="queryParams.unitName"
            placeholder="请输入册别"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="页码" prop="pageNumber">
          <el-input
            v-model.trim="queryParams.pageNumber"
            placeholder="请输入页码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="纸张数量" prop="paperCount">
          <el-input
            v-model.trim="queryParams.paperCount"
            placeholder="请输入纸张数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="打印方式" prop="printMethod">
          <el-input
            v-model.trim="queryParams.printMethod"
            placeholder="请输入打印方式"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="印刷颜色" prop="printColor">
          <el-input
            v-model.trim="queryParams.printColor"
            placeholder="请输入印刷颜色"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="封面材质1" prop="coverMaterialOne">
          <el-input
            v-model.trim="queryParams.coverMaterialOne"
            placeholder="请输入封面材质1"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="封面材质2" prop="coverMaterialTwo">
          <el-input
            v-model.trim="queryParams.coverMaterialTwo"
            placeholder="请输入封面材质2"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="装订方式" prop="bindingMethod">
          <el-input
            v-model.trim="queryParams.bindingMethod"
            placeholder="请输入装订方式"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="WPS云文档的PDF名称" prop="wpsPdfName">
          <el-input
            v-model.trim="queryParams.wpsPdfName"
            placeholder="请输入WPS云文档的PDF名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="旧20位商品编码" prop="oldProductCode">
          <el-input
            v-model.trim="queryParams.oldProductCode"
            placeholder="请输入旧20位商品编码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="新9位商品编码" prop="newProductCode">
          <el-input
            v-model.trim="queryParams.newProductCode"
            placeholder="请输入新9位商品编码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="参考卖点" prop="refSellingPoint">
          <el-input
            v-model.trim="queryParams.refSellingPoint"
            placeholder="请输入参考卖点"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="封面成本" prop="coverCost">
          <el-input
            v-model.trim="queryParams.coverCost"
            placeholder="请输入封面成本"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="每张纸成本" prop="aPaperCost">
          <el-input
            v-model.trim="queryParams.aPaperCost"
            placeholder="请输入每张纸成本"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="纸张成本" prop="paperCost">
          <el-input
            v-model.trim="queryParams.paperCost"
            placeholder="请输入纸张成本"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="复印机耗材" prop="copyMachineConsumablesAmount">
          <el-input
            v-model.trim="queryParams.copyMachineConsumablesAmount"
            placeholder="请输入复印机耗材"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="书本采购价" prop="bookPurchasePrice">
          <el-input
            v-model.trim="queryParams.bookPurchasePrice"
            placeholder="请输入书本采购价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="包装费" prop="pkgCost">
          <el-input
            v-model.trim="queryParams.pkgCost"
            placeholder="请输入包装费"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="书本+包装采购价" prop="bookPackageCost">
          <el-input
            v-model.trim="queryParams.bookPackageCost"
            placeholder="请输入书本+包装采购价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="逻辑删除" prop="isDelete">
          <el-input
            v-model.trim="queryParams.isDelete"
            placeholder="请输入逻辑删除"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
      </div>
      <!-- <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item> -->
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['pdd:BiPddProductCost:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['pdd:BiPddProductCost:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['pdd:BiPddProductCost:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['pdd:BiPddProductCost:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="handleselectMissingCostList"
          >缺失成本SKU数({{ totalCount ? totalCount : 0 }})</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <uploadFile
          @handleSuccess="getList"
          :uploadUrl="'/pdd/BiPddProductCost/importData'"
        />
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="BiPddProductCostList"
      @selection-change="handleSelectionChange"
      :height="650"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />

      <el-table-column label="编码时间" align="center" prop="encodedTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.encodedTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="商品编码" align="center" prop="productCode" />
      <el-table-column
        label="商品名称"
        align="center"
        prop="productName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="文档名称"
        align="center"
        prop="docName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="商品简称"
        align="center"
        prop="productShortName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="物料类别"
        align="center"
        prop="materialCategory"
      />
      <el-table-column label="物料形态" align="center" prop="materialForm" />
      <el-table-column label="教材版本" align="center" prop="textbookVersion" />
      <el-table-column label="教育阶段" align="center" prop="educationStage" />
      <el-table-column label="年级" align="center" prop="gradeLevel" />
      <el-table-column label="学科类别" align="center" prop="subjectCategory" />
      <el-table-column
        label="学科组合"
        align="center"
        prop="subjectCombination"
      />
      <el-table-column label="册别" align="center" prop="unitName" />
      <el-table-column label="页码" align="center" prop="pageNumber" />
      <el-table-column label="纸张数量" align="center" prop="paperCount" />
      <el-table-column label="打印方式" align="center" prop="printMethod" />
      <el-table-column label="印刷颜色" align="center" prop="printColor" />
      <el-table-column
        label="封面材质1"
        align="center"
        prop="coverMaterialOne"
      />
      <el-table-column
        label="封面材质2"
        align="center"
        prop="coverMaterialTwo"
      />
      <el-table-column label="装订方式" align="center" prop="bindingMethod" />
      <el-table-column
        label="WPS云文档的PDF名称"
        align="center"
        prop="wpsPdfName"
      />
      <el-table-column label="资料状态" align="center" prop="dataStatus" />
      <el-table-column
        label="旧20位商品编码"
        align="center"
        prop="oldProductCode"
      />
      <el-table-column
        label="新9位商品编码"
        align="center"
        prop="newProductCode"
      />
      <el-table-column label="参考卖点" align="center" prop="refSellingPoint" />
      <el-table-column label="封面成本" align="center" prop="coverCost" />
      <el-table-column label="每张纸成本" align="center" prop="aPaperCost" />
      <el-table-column label="纸张成本" align="center" prop="paperCost" />
      <el-table-column
        label="复印机耗材"
        align="center"
        prop="copyMachineConsumablesAmount"
      />
      <el-table-column
        label="书本采购价"
        align="center"
        prop="bookPurchasePrice"
      />
      <el-table-column label="包装费" align="center" prop="pkgCost" />
      <el-table-column
        label="书本+包装采购价"
        align="center"
        prop="bookPackageCost"
      />
      <el-table-column label="逻辑删除" align="center" prop="isDelete" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['pdd:BiPddProductCost:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['pdd:BiPddProductCost:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="MissingCost == '0'"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <pagination
      v-show="MissingCost == '1'"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="handleselectMissingCostList"
    />

    <!-- 添加或修改拼多多商品成本对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1000px"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row :gutter="10" class="mb8">
          <el-col :span="12">
            <el-form-item label="编码时间" prop="encodedTime">
              <el-date-picker
                clearable
                v-model="form.encodedTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择编码时间"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item label="商品编码" prop="productCode">
              <el-input
                v-model.trim="form.productCode"
                placeholder="请输入商品编码"
              />
            </el-form-item>
            <el-form-item label="商品名称" prop="productName">
              <el-input
                v-model.trim="form.productName"
                placeholder="请输入商品名称"
              />
            </el-form-item>
            <el-form-item label="文档名称" prop="docName">
              <el-input
                v-model.trim="form.docName"
                placeholder="请输入文档名称"
              />
            </el-form-item>
            <el-form-item label="商品简称" prop="productShortName">
              <el-input
                v-model.trim="form.productShortName"
                placeholder="请输入商品简称"
              />
            </el-form-item>
            <el-form-item label="物料类别" prop="materialCategory">
              <el-input
                v-model.trim="form.materialCategory"
                placeholder="请输入物料类别"
              />
            </el-form-item>
            <el-form-item label="物料形态" prop="materialForm">
              <el-input
                v-model.trim="form.materialForm"
                placeholder="请输入物料形态"
              />
            </el-form-item>
            <el-form-item label="教材版本" prop="textbookVersion">
              <el-input
                v-model.trim="form.textbookVersion"
                placeholder="请输入教材版本"
              />
            </el-form-item>
            <el-form-item label="教育阶段" prop="educationStage">
              <el-input
                v-model.trim="form.educationStage"
                placeholder="请输入教育阶段"
              />
            </el-form-item>
            <el-form-item label="年级" prop="gradeLevel">
              <el-input
                v-model.trim="form.gradeLevel"
                placeholder="请输入年级"
              />
            </el-form-item>
            <el-form-item label="学科类别" prop="subjectCategory">
              <el-input
                v-model.trim="form.subjectCategory"
                placeholder="请输入学科类别"
              />
            </el-form-item>
            <el-form-item label="学科组合" prop="subjectCombination">
              <el-input
                v-model.trim="form.subjectCombination"
                placeholder="请输入学科组合"
              />
            </el-form-item>
            <el-form-item label="册别" prop="unitName">
              <el-input v-model.trim="form.unitName" placeholder="请输入册别" />
            </el-form-item>
            <el-form-item label="页码" prop="pageNumber">
              <el-input
                v-model.trim="form.pageNumber"
                placeholder="请输入页码"
              />
            </el-form-item>
            <el-form-item label="纸张数量" prop="paperCount">
              <el-input
                v-model.trim="form.paperCount"
                placeholder="请输入纸张数量"
              />
            </el-form-item>
            <el-form-item label="打印方式" prop="printMethod">
              <el-input
                v-model.trim="form.printMethod"
                placeholder="请输入打印方式"
              />
            </el-form-item>
            <el-form-item label="印刷颜色" prop="printColor">
              <el-input
                v-model.trim="form.printColor"
                placeholder="请输入印刷颜色"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="封面材质1" prop="coverMaterialOne">
              <el-input
                v-model.trim="form.coverMaterialOne"
                placeholder="请输入封面材质1"
              />
            </el-form-item>

            <el-form-item label="封面材质2" prop="coverMaterialTwo">
              <el-input
                v-model.trim="form.coverMaterialTwo"
                placeholder="请输入封面材质2"
              />
            </el-form-item>
            <el-form-item label="装订方式" prop="bindingMethod">
              <el-input
                v-model.trim="form.bindingMethod"
                placeholder="请输入装订方式"
              />
            </el-form-item>

            <el-form-item label="WPS云文档的PDF名称" prop="wpsPdfName">
              <el-input
                v-model.trim="form.wpsPdfName"
                placeholder="请输入WPS云文档的PDF名称"
              />
            </el-form-item>
            <el-form-item label="旧20位商品编码" prop="oldProductCode">
              <el-input
                v-model.trim="form.oldProductCode"
                placeholder="请输入旧20位商品编码"
              />
            </el-form-item>
            <el-form-item label="新9位商品编码" prop="newProductCode">
              <el-input
                v-model.trim="form.newProductCode"
                placeholder="请输入新9位商品编码"
              />
            </el-form-item>
            <el-form-item label="参考卖点" prop="refSellingPoint">
              <el-input
                v-model.trim="form.refSellingPoint"
                placeholder="请输入参考卖点"
              />
            </el-form-item>
            <el-form-item label="封面成本" prop="coverCost">
              <el-input
                v-model.trim="form.coverCost"
                placeholder="请输入封面成本"
              />
            </el-form-item>
            <el-form-item label="每张纸成本" prop="aPaperCost">
              <el-input
                v-model.trim="form.aPaperCost"
                placeholder="请输入每张纸成本"
              />
            </el-form-item>
            <el-form-item label="纸张成本" prop="paperCost">
              <el-input
                v-model.trim="form.paperCost"
                placeholder="请输入纸张成本"
              />
            </el-form-item>
            <el-form-item
              label="复印机耗材"
              prop="copyMachineConsumablesAmount"
            >
              <el-input
                v-model.trim="form.copyMachineConsumablesAmount"
                placeholder="请输入复印机耗材"
              />
            </el-form-item>
            <el-form-item label="书本采购价" prop="bookPurchasePrice">
              <el-input
                v-model.trim="form.bookPurchasePrice"
                placeholder="请输入书本采购价"
              />
            </el-form-item>
            <el-form-item label="包装费" prop="pkgCost">
              <el-input
                v-model.trim="form.pkgCost"
                placeholder="请输入包装费"
              />
            </el-form-item>
            <el-form-item label="书本+包装采购价" prop="bookPackageCost">
              <el-input
                v-model.trim="form.bookPackageCost"
                placeholder="请输入书本+包装采购价"
              />
            </el-form-item>
            <el-form-item label="逻辑删除" prop="isDelete">
              <el-input
                v-model.trim="form.isDelete"
                placeholder="请输入逻辑删除"
              />
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input v-model.trim="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listBiPddProductCost,
  getBiPddProductCost,
  delBiPddProductCost,
  addBiPddProductCost,
  updateBiPddProductCost,
  selectMissingCostList,
} from "@/api/pdd/BiPddProductCost";

export default {
  name: "BiPddProductCost",
  data() {
    return {
      MissingCost: "0",
      isOpen: false,
      inputValue: "",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      totalCount: 0,
      // 总条数
      total: 0,
      // 拼多多商品成本表格数据
      BiPddProductCostList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        encodedTime: null,
        productCode: null,
        productName: null,
        docName: null,
        productShortName: null,
        materialCategory: null,
        materialForm: null,
        textbookVersion: null,
        educationStage: null,
        gradeLevel: null,
        subjectCategory: null,
        subjectCombination: null,
        unitName: null,
        pageNumber: null,
        paperCount: null,
        printMethod: null,
        printColor: null,
        coverMaterialOne: null,
        coverMaterialTwo: null,
        bindingMethod: null,
        wpsPdfName: null,
        dataStatus: null,
        oldProductCode: null,
        newProductCode: null,
        refSellingPoint: null,
        coverCost: null,
        aPaperCost: null,
        paperCost: null,
        copyMachineConsumablesAmount: null,
        bookPurchasePrice: null,
        pkgCost: null,
        bookPackageCost: null,
        isDelete: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    selectMissingCostList(this.queryParams).then((response) => {
      this.totalCount = response.total;
    });
    this.getList();
  },
  methods: {
    handleselectMissingCostList() {
      this.MissingCost = "1";
      selectMissingCostList(this.queryParams).then((response) => {
        this.BiPddProductCostList = response.rows;
        this.total = response.total;
      });
    },
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询拼多多商品成本列表 */
    getList() {
      this.loading = true;
      this.MissingCost = "0";
      listBiPddProductCost(this.queryParams).then((response) => {
        this.BiPddProductCostList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        encodedTime: null,
        productCode: null,
        productName: null,
        docName: null,
        productShortName: null,
        materialCategory: null,
        materialForm: null,
        textbookVersion: null,
        educationStage: null,
        gradeLevel: null,
        subjectCategory: null,
        subjectCombination: null,
        unitName: null,
        pageNumber: null,
        paperCount: null,
        printMethod: null,
        printColor: null,
        coverMaterialOne: null,
        coverMaterialTwo: null,
        bindingMethod: null,
        wpsPdfName: null,
        dataStatus: null,
        oldProductCode: null,
        newProductCode: null,
        refSellingPoint: null,
        coverCost: null,
        aPaperCost: null,
        paperCost: null,
        copyMachineConsumablesAmount: null,
        bookPurchasePrice: null,
        pkgCost: null,
        bookPackageCost: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        isDelete: null,
        remark: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加拼多多商品成本";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getBiPddProductCost(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改拼多多商品成本";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateBiPddProductCost(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addBiPddProductCost(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除拼多多商品成本编号为"' + ids + '"的数据项？')
        .then(function () {
          return delBiPddProductCost(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "pdd/BiPddProductCost/export",
        {
          ...this.queryParams,
        },
        `BiPddProductCost_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
